package Test_1130;

import java.util.Arrays;
import java.util.Random;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class Test {
    public static void main(String[] args) {
        testSimple();
       // testOther();
    }
    //初始化数组
    public static void orderArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i]=i;
            //array[i]= array.length-1;
        }
    }

    public static void notOrderArray(int[] array) {
        Random random=new Random();
        for (int i = 0; i < array.length; i++) {
            //为什么要加下划线
            array[i]=random.nextInt(10_0000);
        }
    }
    //将初始化数组进行排序
    public static void testSimple() {
        int[] array={12,5,2,9,18,7};
        System.out.println("排序前"+ Arrays.toString(array));
        Sort.selectSort(array);
        System.out.println("排序后"+ Arrays.toString(array));
    }
    public static void testOther(){
        int[] array=new int[100000];
        orderArray(array);
        testInsert(array);
        testShellSort(array);
    }
//测试简单数据能否执行，算法是否正确
    public static void testInsert(int[] array) {
        array=Arrays.copyOf(array,array.length);
        //这个有什么用
        long startTime=System.currentTimeMillis();
        Sort.insetSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("直接插入排序耗时"+(endTime-startTime));
    }
    public static void testShellSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println("希尔排序耗时"+(endTime-startTime));

    }}
